package com.stx.House.CGLIB;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class HouseAgentByDynamicForCglib implements MethodInterceptor {
    private HouseOwner owner;

    public HouseAgentByDynamicForCglib(HouseOwner owner) {
        this.owner = owner;
    }
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println("中介替购房者完成筛选房屋...最终选定了一间房。");


        Object result = method.invoke(owner, objects);

        System.out.println("中介替购房者完成与房主签订的售房合同。");
        return result;
    }
}
